#DEVICE_MODEL ?= arm_a5
#DEVICE_MODEL ?= arm_a5_vmf
#DEVICE_MODEL ?= x86_win64
#DEVICE_MODEL ?= x86_linux64
DEVICE_MODEL ?= platform

INC_PATH := $(CURDIR)/$(DEVICE_MODEL)/include
LIB_PATH := $(CURDIR)/$(DEVICE_MODEL)/lib
BIN_PATH := $(CURDIR)/$(DEVICE_MODEL)/bin
DBG_PATH := $(CURDIR)/$(DEVICE_MODEL)/objs

# Hisilicon arm_a5 inception
ifeq ($(DEVICE_MODEL),platform)
PRODUCT_CLASS := finder
PRODUCT_MODEL := finder-inception
SOC_MODEL := arm
CROSS := arm-linux-
endif

# Hisilicon arm_a5 inception
ifeq ($(DEVICE_MODEL),arm_a5)
PRODUCT_CLASS := finder
PRODUCT_MODEL := finder-inception
SOC_MODEL := arm
CROSS := arm-linux-
endif

# Hisilicon arm_a5_vmf inception
ifeq ($(DEVICE_MODEL),arm_a5_vmf)
PRODUCT_CLASS := finder
PRODUCT_MODEL := finder-inception
SOC_MODEL := arm
CROSS := arm-linux-
endif

# x86 windows-64 inception
ifeq ($(DEVICE_MODEL),x86_win64)
PRODUCT_CLASS := finder
PRODUCT_MODEL := finder-inception
SOC_MODEL := x86
CROSS :=
SERISE_CODE := C1
endif

MAKE := @make

.PHONY: all src srclib sdk_clean tarball
	
#info:
#	@echo $(PRODUCT_CLASS)
#	@echo $(PRODUCT_MODEL)
#	@echo $(SOC_MODEL)
#

src:
	$(MAKE) -C $(DEVICE_MODEL) CROSS="@$(CROSS)" \
		PRODUCT_CLASS="$(PRODUCT_CLASS)" \
		PRODUCT_MODEL="$(PRODUCT_MODEL)" \
		SOC_MODEL="$(SOC_MODEL)" \
		INC_PATH="$(INC_PATH)" \
		LIB_PATH="$(LIB_PATH)" \
		BIN_PATH="$(BIN_PATH)" \
		DBG_PATH="$(DBG_PATH)" \
		SERISE_CODE="$(SERISE_CODE)" \

srclib:
	rm -f $(BIN_PATH)/*
	$(MAKE) -C $(DEVICE_MODEL) srclib CROSS="@$(CROSS)" \
		PRODUCT_CLASS="$(PRODUCT_CLASS)" \
		PRODUCT_MODEL="$(PRODUCT_MODEL)" \
		SOC_MODEL="$(SOC_MODEL)" \
		INC_PATH="$(INC_PATH)" \
		LIB_PATH="$(LIB_PATH)" \
		BIN_PATH="$(BIN_PATH)" \
		DBG_PATH="$(DBG_PATH)" \
		SERISE_CODE="$(SERISE_CODE)" \

tarball:
	$(MAKE) --directory=sdk clean
	
release:
	@if [ ! -d platform ]; then mkdir -p platform; fi;\
	set -e; rm -rf platform/*;\
	set -e; cp -rf $(DEVICE_MODEL)/include ./platform/;\
	set -e; cp -rf $(DEVICE_MODEL)/lib ./platform/;\
	set -e; cp -rf $(DEVICE_MODEL)/Makefile ./platform/Makefile;
	
all: clean src srclib

clean:
	rm -f $(shell find $(CURDIR) -name *.o)
	rm -f $(shell find $(CURDIR) -name *.d)
